package io.github.codelifeleno.jdbrelease.model;

import java.util.Objects;
import java.util.StringJoiner;

public class ScriptFile {
    private String id;
    private String simpleFilename;
    private String rollbackFilename;
    private boolean isRepeatable;

    @Override
    public String toString() {
        return new StringJoiner(", ", ScriptFile.class.getSimpleName() + "[", "]")
                .add("id='" + id + "'")
                .add("simpleFilename='" + simpleFilename + "'")
                .add("rollbackFilename='" + rollbackFilename + "'")
                .add("isRepeatable=" + isRepeatable)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;

        ScriptFile that = (ScriptFile) o;
        return isRepeatable() == that.isRepeatable() && Objects.equals(getId(), that.getId()) && Objects.equals(getSimpleFilename(), that.getSimpleFilename()) && Objects.equals(getRollbackFilename(), that.getRollbackFilename());
    }

    @Override
    public int hashCode() {
        int result = Objects.hashCode(getId());
        result = 31 * result + Objects.hashCode(getSimpleFilename());
        result = 31 * result + Objects.hashCode(getRollbackFilename());
        result = 31 * result + Boolean.hashCode(isRepeatable());
        return result;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSimpleFilename() {
        return simpleFilename;
    }

    public void setSimpleFilename(String simpleFilename) {
        this.simpleFilename = simpleFilename;
    }

    public String getRollbackFilename() {
        return rollbackFilename;
    }

    public void setRollbackFilename(String rollbackFilename) {
        this.rollbackFilename = rollbackFilename;
    }

    public boolean isRepeatable() {
        return isRepeatable;
    }

    public void setRepeatable(boolean repeatable) {
        isRepeatable = repeatable;
    }

    public ScriptFile(String id, String simpleFilename, String rollbackFilename, boolean isRepeatable) {
        this.id = id;
        this.simpleFilename = simpleFilename;
        this.rollbackFilename = rollbackFilename;
        this.isRepeatable = isRepeatable;
    }
}
